-------------- lich su truy cap --------------
-----------Xem thong tin lich su truy cap----------
if exists (select name from sysobjects where name like 'Proc_LichSuTruyCap_GetById')
	drop procedure Proc_LichSuTruyCap_GetById
go

create PROC Proc_LichSuTruyCap_GetById (@maLS int )
as
	select * from LichSuTruyCap
	where Ma = @maLS
go

Exec Proc_LichSuTruyCap_GetById 1
go


------------------------------------------------
------- them lich su truy cap-------------
if exists (select name from sysobjects where name like 'Proc_LichSuTruyCap_Add')
	drop procedure Proc_LichSuTruyCap_Add
go

create PROC Proc_LichSuTruyCap_Add (@maTK int ,  @ngayTruyCap datetime)
as
	insert into LichSuTruyCap(MaTK,NgayTruyCap)
	values (@maTK,@ngayTruyCap) 
go

Exec Proc_LichSuTruyCap_Add 1,'06/12/2004'
go

select * from LichSuTruyCap
go

---------------------------------------------
-------- Ma Tai khoan -------------------
if exists (select name from sysobjects where name like 'Proc_LichSuTruyCap_GetByMaTaiKhoan')
	drop procedure Proc_LichSuTruyCap_GetByMaTaiKhoan
go

create PROC Proc_LichSuTruyCap_GetByMaTaiKhoan (@maTK int )
as
	select * from LichSuTruyCap
	where MaTK = @maTK
go

Exec Proc_LichSuTruyCap_GetByMaTaiKhoan 1
go

----------------------------------------------
----------------- tim lan truy cap gan nhat----------------------

if exists (select name from sysobjects where name like 'Proc_LichSuTruyCap_GetLastLoginByMaTaiKhoan')
	drop procedure Proc_LichSuTruyCap_GetLastLoginByMaTaiKhoan
go

create PROC Proc_LichSuTruyCap_GetLastLoginByMaTaiKhoan(@maTK int )
as
	select * from LichSuTruyCap where MaTK = @maTK
	order by NgayTruyCap desc
	
go

Exec Proc_LichSuTruyCap_GetLastLoginByMaTaiKhoan 1
go
